package com.wendy.generator.config;

import com.wendy.common.core.constant.ConfigConstant;
import com.wendy.common.web.Interceptor.PageInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 *
 * @author wendy
 */
@Configuration
public class GenWebMvcConfig implements WebMvcConfigurer
{
    /** 不需要拦截地址 */
    public static final String[] excludeUrls = ConfigConstant.excludeUrls;

    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(pageInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(excludeUrls)
                .order(-9);
    }

    /**
     * 自定义请求头拦截器
     */
    @Bean
    public PageInterceptor pageInterceptor()
    {
         PageInterceptor pg=new PageInterceptor();
        return pg;
    }

}
